package com.ncwu.order.controller;


import com.ncwu.order.bean.Order;
import com.ncwu.order.properties.OrderProperties;
import com.ncwu.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private OrderProperties orderProperties;

    @GetMapping("order")
    public Order getOrder(@RequestParam(required = false) Long productId,
                          @RequestParam("userId") Long userId){
    Order order  = orderService.getOrder(productId,userId);
    return order;
    }


    @GetMapping("config")
    public String config(){
        return orderProperties.getTimeout() + " " + orderProperties.getAutoConfirm();
    }

}
